package ioc

import (
	"forum/internal/adapter/driven/middleware"
	"forum/internal/application"
	middleware2 "forum/pkg/ginx/middleware"
	"github.com/gin-gonic/gin"
	"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
)

func InitMiddleware(handler *application.JwtServiceImp) []gin.HandlerFunc {
	pb := middleware2.NewPrometheusBuilder(
		"geekmokou",
		"forum",
		"gin_http",
		"统计 GIN 的HTTP接口数据")
	return []gin.HandlerFunc{
		middleware.NewAuthMiddlewareBuilder(handler).
			Ignore("/user/login").
			Ignore("/user/signup").
			Ignore("/user/refreshToken").
			Build(),
		pb.BuildResponseTime(),
		pb.BuildActiveRequest(),
		otelgin.Middleware("forum"),
	}
}
